﻿/*
Copyright (C) 2009 Dumitru Condrea

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

//var currenciesList = ["AED", "AMD", "AUD", "AZN", "BGN", "BYR", "CAD", "CHF", "CNY", "CZK", "DKK", "EEK", "EUR", "GBP", "GEL", "HRK", "HUF", "ILS", "ISK", "JPY", "KGS", "KWD", "KZT", "LTL", "LVL", "MDL", "NOK", "NZD", "PLN", "RON", "RSD", "RUB", "SEK", "TJS", "TMT", "TRY", "UAH", "USD", "UZS", "XDR"];
var currenciesList = ["AED", //UAE Dirham
"ALL", //Albanian Lek
"ANG", //Neth Antilles Guilder
"ARS", //Argentine Peso
"AUD", //Australian dollar
"AWG", //Aruba Florin
"BBD", //Barbados Dollar
"BDT", //Bangladesh Taka
"BGN", //Bulgarian Lev
"BHD", //Bahraini Dinar
"BIF", //Burundi Franc
"BMD", //Bermuda Dollar
"BND", //Brunei Dollar
"BOB", //Bolivian Boliviano
"BRL", //Brazilian Real
"BSD", //Bahamian Dollar
"BTN", //Bhutan Ngultrum
"BWP", //Botswana Pula
"BYR", //Belarus Ruble
"BZD", //Belize Dollar
"CAD", //Canadian dollar
"CHF", //Swiss franc
"CLP", //Chilean Peso
"CNY", //Chinese Yuan
"CNY", //Renminbi
"COP", //Colombian Peso
"CRC", //Costa Rica Colon
"CUP", //Cuban Peso
"CVE", //Cape Verde Escudo
"CYP", //Cyprus Pound
"CZK", //Czech Koruna
"DJF", //Dijibouti Franc
"DKK", //Danish Krone
"DOP", //Dominican Peso
"DZD", //Algerian Dinar
"ECS", //Ecuador Sucre
"EEK", //Estonian Kroon
"EGP", //Egyptian Pound
"ERN", //Eritrea Nakfa
"ETB", //Ethiopian Birr
"EUR", //Euro
"FJD", //Fiji Dollar
"FKP", //Falkland Islands Pound
"GBP", //British Pound
"GHC", //Ghanian Cedi
"GIP", //Gibraltar Pound
"GMD", //Gambian Dalasi
"GNF", //Guinea Franc
"GTQ", //Guatemala Quetzal
"GYD", //Guyana Dollar
"HKD", //Hong Kong dollar
"HNL", //Honduras Lempira
"HRK", //Croatian Kuna
"HTG", //Haiti Gourde
"HUF", //Hungarian Forint
"IDR", //Indonesian rupiah
"ILS", //Israeli Shekel
"INR", //Indian rupee
"IQD", //Iraqi Dinar
"IRR", //Iran Rial
"ISK", //Iceland Krona
"JMD", //Jamaican Dollar
"JOD", //Jordanian Dinar
"JPY", //Japanese yen
"KES", //Kenyan Shilling
"KHR", //Cambodia Riel
"KMF", //Comoros Franc
"KPW", //North Korean Won
"KRW", //Korean Won
"KWD", //Kuwaiti Dinar
"KYD", //Cayman Islands Dollar
"KZT", //Kazakhstan Tenge
"LAK", //Lao Kip
"LBP", //Lebanese Pound
"LKR", //Sri Lanka Rupee
"LRD", //Liberian Dollar
"LSL", //Lesotho Loti
"LTL", //Lithuanian Lita
"LVL", //Latvian Lat
"LYD", //Libyan Dinar
"MAD", //Moroccan Dirham
"MDL", //Moldovan Leu
"MKD", //Macedonian Denar
"MMK", //Myanmar Kyat
"MNT", //Mongolian Tugrik
"MOP", //Macau Pataca
"MRO", //Mauritania Ougulya
"MTL", //Maltese Lira
"MUR", //Mauritius Rupee
"MVR", //Maldives Rufiyaa
"MWK", //Malawi Kwacha
"MXN", //Mexican Peso
"MYR", //Malaysian Ringgit
"NAD", //Namibian Dollar
"NGN", //Nigerian Naira
"NIO", //Nicaragua Cordoba
"NOK", //Norwegian Krone
"NPR", //Nepalese Rupee
"NZD", //New Zealand Dollar
"OMR", //Omani Rial 
"PAB", //Panama Balboa
"PEN", //Peruvian Nuevo Sol
"PGK", //Papua New Guinea Kina
"PHP", //Philippine Peso
"PKR", //Pakistani Rupee
"PLN", //Polish Zloty
"PYG", //Paraguayan Guarani
"QAR", //Qatar Rial
"RON", //Romanian New Leu
"RUB", //Russian Rouble
"RWF", //Rwanda Franc
"SAR", //Saudi Arabian Riyal
"SBD", //Solomon Islands Dollar
"SCR", //Seychelles Rupee
"SDD", //Sudanese Dinar
"SEK", //Swedish Krona
"SGD", //Singapore Dollar
"SHP", //St Helena Pound
"SIT", //Slovenian Tolar
"SKK", //Slovak Koruna
"SLL", //Sierra Leone Leone
"SOS", //Somali Shilling
"STD", //Sao Tome Dobra
"SVC", //El Salvador Colon
"SYP", //Syrian Pound
"SZL", //Swaziland Lilageni
"THB", //Thai baht
"TND", //Tunisian Dinar
"TOP", //Tonga Pa'anga
"TRY", //Turkish Lira
"TTD", //Trinidad & Tobago Dollar
"TWD", //Taiwan Dollar
"TZS", //Tanzanian Shilling
"UAH", //Ukraine Hryvnia
"UGX", //Ugandan Shilling
"USD", //United States dollar
"UYU", //Uruguayan New Peso
"VEB", //Venezuelan Bolivar
"VND", //Vietnam Dong
"VUV", //Vanuatu Vatu
"WST", //Samoa Tala
"XAF", //CFA Franc (BEAC)
"XAG", //Silver Ounces
"XAL", //Aluminium Ounces
"XAU", //Gold Ounces
"XCD", //East Caribbean Dollar
"XCP", //Copper Pounds
"XOF", //CFA Franc (BCEAO)
"XPD", //Palladium Ounces
"XPF", //Pacific Franc
"XPT", //Platinum Ounces
"YER", //Yemen Riyal
"ZAR", //South African Rand
"ZMK", //Zambian Kwacha
"ZWD" //Zimbabwe Dollar
];

function options_onOpen() {
    txtNewMin.value = options("Min");

    cbC1.removeAllElements();
    cbC2.removeAllElements();

    for (var i = 0; i < currenciesList.length; i++) {
        cbC1.appendString(currenciesList[i]);
        cbC2.appendString(currenciesList[i]);
    }

    cbC1.selectedIndex = currenciesList.indexOf(options("C1"));
    cbC2.selectedIndex = currenciesList.indexOf(options("C2"));
}

function options_onOk() {
    if (!txtNewMin.value.isNumeric()) {
        view.alert(strErr02);
        return false;
    }
    
    if (txtNewMin.value < 1) {
        view.alert(strErr01);
        return false;
    } 

    options("Min") = txtNewMin.value;
    options("C1") = cbC1.value;
    options("C2") = cbC2.value;
    gadget.debug.trace("options saved.");
}

function options_onCancel() {
    gadget.debug.trace("options canceled.");
}